#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <set>
#include <queue>

using namespace std;
using LL = long long;
using PII = pair<int, int>;
const int N = 1e5 + 10;

int n, m;
struct Hance{
    LL a, b, c, val, cur;

    bool operator< (const Hance& w)const{
        return val > w.val;
    }
}hanc[N];

priority_queue<Hance> q;

LL f(LL a, LL b, LL c,  LL x){
    LL res = a * x * x + b * x + c;
    return res;
}

int main(){
#ifdef LOCALFLAG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif


    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> m;

    for(int i = 1; i <= n; i ++){
        cin >> hanc[i].a >> hanc[i].b >> hanc[i].c;
        hanc[i].cur = 1;
        hanc[i].val = f(hanc[i].a, hanc[i].b, hanc[i].c, hanc[i].cur);
        q.push(hanc[i]);
    }

    for(int i = 1; i <= m; i ++){
        Hance temp = q.top();
        q.pop();

        cout << temp.val << " ";
        temp.cur = temp.cur + 1;
        temp.val = f(temp.a, temp.b, temp.c, temp.cur);
        q.push(temp);
    }

    return 0;
}